<template>
  <div class="toPayment">
    <el-form :model="updateForm" label-width="100px" v-if="parkData" :rules="rules">
      停车场：
      <el-form-item label="开户名称:">{{parkData.accountName}}</el-form-item>
      <el-form-item label="开户银行:">{{parkData.bankName}}</el-form-item>
      <el-form-item label="银行账号:">{{parkData.bankAccount}}</el-form-item>
      <el-form-item label="打款单号:" prop="paidToParkTradeNo">
        <el-input size="mini" v-model.number="updateForm.paidToParkTradeNo" style="width: 300px;"></el-input>
      </el-form-item>
    </el-form>

    <el-form :model="updateForm" label-width="100px" v-if="shopData">
      商户：
      <el-form-item label="开户名称:">{{shopData.accountName}}</el-form-item>
      <el-form-item label="开户银行:">{{shopData.bankName}}</el-form-item>
      <el-form-item label="银行账号:">{{shopData.bankAccount}}</el-form-item>
      <el-form-item label="打款单号:" prop="paidToShopTradeNo">
        <el-input size="mini" v-model.number="updateForm.paidToShopTradeNo" style="width: 300px;"></el-input>
      </el-form-item>
    </el-form>

    <p style="text-align: center;">
      <el-button size="mini" @click="$emit('closeDialog')">取消</el-button>
      <el-button size="mini" type="primary" @click="submit">确定</el-button>
    </p>

  </div>
</template>

<script>
  export default {
    props: ['row'],
    data() {
      return {
        shopData: {},
        parkData: {},
        updateForm: {},
        rules: {
          paidToParkTradeNo: [
            { required: true, message: '请输入打款单号', trigger: 'blur' }
          ],
          paidToShopTradeNo: [
            { required: true, message: '请输入打款单号', trigger: 'blur' }
          ]
        }
      }
    },

    mounted() {
      this.getBankInfo(this.row)
      this.updateForm.id = this.row.id;
      this.updateForm.businessType = this.row.businessType;

    },

    methods: {
      getBankInfo(row) {
        this.$axios({
          method: 'get',
          url: '/shop/shop-order/get-bank-info',
          params: row
        }).then((res) => {
          if(res.code == 200) {
            this.shopData = res.data.shop;
            this.parkData = res.data.park;
          }
        })
      },

      submit() {
        this.$axios({
          method: 'post',
          url: '/shop/shop-order/update-payment',
          data: this.updateForm
        }).then((res) => {
          if(res.code == 200) {
            this.$message.success('修改打款状态成功');
            this.$emit('closeDialog');
            this.$emit('refresh');
          }
        })
      }
    }
  }
</script>

<style scoped>
  .el-form-item {
    padding: 0;
    margin: 0;
  }





</style>
